package com.lzy.huijinjiazu.mvp.ui.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.jess.arms.base.BaseFragment;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;
import com.lzy.huijinjiazu.R;
import com.lzy.huijinjiazu.di.component.DaggerPersonalTailorComponent;
import com.lzy.huijinjiazu.di.module.PersonalTailorModule;
import com.lzy.huijinjiazu.mvp.contract.PersonalTailorContract;
import com.lzy.huijinjiazu.mvp.presenter.PersonalTailorPresenter;
import com.lzy.huijinjiazu.mvp.ui.adapter.TourismAdapter;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;

import static com.jess.arms.utils.Preconditions.checkNotNull;


public class PersonalTailorFragment extends BaseFragment<PersonalTailorPresenter> implements PersonalTailorContract.View {


    @BindView(R.id.rv_list)
    RecyclerView mRvList;
    private TourismAdapter mAdapter;

    public static PersonalTailorFragment newInstance() {
        PersonalTailorFragment fragment = new PersonalTailorFragment();
        return fragment;
    }

    @Override
    public void setupFragmentComponent(AppComponent appComponent) {
        DaggerPersonalTailorComponent //如找不到该类,请编译一下项目
                .builder()
                .appComponent(appComponent)
                .personalTailorModule(new PersonalTailorModule(this))
                .build()
                .inject(this);
    }

    @Override
    public View initView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_personal_tailor, container, false);
    }

    @Override
    public void initData(Bundle savedInstanceState) {
        initRecyclerView();
        listData();
    }

    private void initRecyclerView() {
        ArmsUtils.configRecyclerView(mRvList, new LinearLayoutManager(getContext()) {
            @Override
            public boolean canScrollVertically() {
                return false;
            }
        });
        mAdapter = new TourismAdapter();
        mRvList.setAdapter(mAdapter);
    }

    private void listData() {
        List<String> data = new ArrayList<>();
        for (int i = 0; i < 3; i++) {
            data.add("");
        }
        mAdapter.setNewData(data);
    }
}
